package com.maoyongjian.dome1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maoyongjian.dome1.entity.Manager;
import com.maoyongjian.dome1.mapper.ManagerMapper;
import com.maoyongjian.dome1.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ManagerServiceImpl extends ServiceImpl<ManagerMapper, Manager> implements ManagerService{

    @Autowired
    private ManagerMapper managerMapper;
    @Override
    public void add(Manager manager){
        QueryWrapper<Manager> wrapper = new QueryWrapper<>();
        wrapper.eq("account",manager.getAccount());
        boolean exists = managerMapper.exists(wrapper);
        if (exists){
           throw new ArithmeticException("账号"+manager.getAccount()+"已存在");
        }else {
            managerMapper.insert(manager);
        }

    }
}
